'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  up: (queryInterface, Sequelize) => {
    const { INTEGER, STRING, DATE, ENUM, TEXT } = Sequelize;
    return queryInterface.createTable("category", {
      id: {
        type: INTEGER(20),
        primaryKey: true,
        autoIncrement: true,
      },
      pid: {
        type: INTEGER(1),
        allowNull: false,
        defaultValue: 0,
        comment: "上级栏目id",
      },
      type: {
        type: INTEGER(1),
        allowNull: false,
        defaultValue: 1,
        comment: "栏目类型 1文章 2图片",
      },
      title: {
        type: STRING(30),
        allowNull: false,
        defaultValue: "",
        comment: "栏目名称",
      },
      thumb: {
        type: STRING(1000),
        allowNull: true,
        defaultValue: "",
        comment: "栏目图片",
      },
      keywords: {
        type: STRING(80),
        allowNull: true,
        defaultValue: "",
        comment: "关键词",
      },
      description: {
        type: STRING(255),
        allowNull: true,
        defaultValue: "",
        comment: "描述",
      },
      islink: {
        type: INTEGER(1),
        allowNull: true,
        defaultValue: 0,
        comment: "是否外链 0否 1是",
      },
      url: {
        type: STRING(255),
        allowNull: true,
        defaultValue: "",
        comment: "外链网址",
      },
      posid: {
        type: INTEGER(1),
        allowNull: true,
        defaultValue: 0,
        comment: "推荐位 1焦点 2头条 3推荐",
      },
      order: {
        type: INTEGER(60),
        allowNull: true,
        defaultValue: 0,
        comment: "排序",
      },
      status: {
        type: INTEGER(1),
        allowNull: false,
        defaultValue: 1,
        comment: "状态 0取消 1正常",
      }, 
      created_time: DATE,
      updated_time: DATE,
    });
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.dropTable("category");
  },
};
